package chapter04

import scala.util.control.Breaks

object Test06_Break {
  def main(args: Array[String]): Unit = {
    try {
      for (i <- 0 until 5) {
        if (i == 3) throw new RuntimeException
        println("i =" + i)
      }
    } catch {
      case e: Exception =>
    }
    println("这是循环外")

    //使用scala的Break类方法
    Breaks.breakable(
      for (i <- 0 until 5) {
        if (i == 3) Breaks.break()
        println("i =" + i)
      }
    )

  }
}
